﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/SiteAdmin.Master" AutoEventWireup="true" CodeBehind="ManageRoles.aspx.cs" Inherits="WebApplication1.Admin.ManageRoles1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script type="text/javascript" language="javascript" >
    function validateTextBox() {
        if (document.getElementById('txtRoleName').value == "") {
            alert("The Role Name Cannot Be Empty");
            document.getElementById('txtRoleName').focus();
            return false;
        }
        else {
            return true;
        }
    }
</script>
<table>
<tr>
<td>
    <asp:Label ID="lblRoleResult" runat="server" ForeColor="Red"></asp:Label>
    </td>
</tr>
<tr>
<td>
    <p style="text-align:right;"><asp:Button ID="btnRoleAdd" runat="Server" Text="Add New Role" OnClick="AddNewRecord" /></p>
    <asp:GridView ID="gvRoles" runat="server" AutoGenerateColumns="False" 
        BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" 
        CellPadding="3" CellSpacing="1" GridLines="None" 
        onrowcancelingedit="gvRoles_RowCancelingEdit" 
        onrowdeleting="gvRoles_RowDeleting" onrowediting="gvRoles_RowEditing" 
        onrowupdating="gvRoles_RowUpdating" 
        onselectedindexchanged="gvRoles_SelectedIndexChanged" Width="643px" 
        onrowcommand="gvRoles_RowCommand">
        <Columns>
            <asp:CommandField HeaderText="Edit" ShowEditButton="True">
            <HeaderStyle HorizontalAlign="Left" />
            </asp:CommandField>
            <asp:TemplateField HeaderText="Delete?" >
               <ItemTemplate>
                  <span onclick="return confirm('Are you sure to Delete the record?')">
                    <asp:LinkButton ID="lnkB" runat="Server" Text="Delete" CommandName="Delete"></asp:LinkButton>
                        </span>
               </ItemTemplate>
                  
             </asp:TemplateField>
            <asp:TemplateField HeaderText="Role Id" ShowHeader="False" >
                <HeaderStyle HorizontalAlign="Left" />
                <ItemTemplate>
                    <asp:HiddenField ID="hdRoleId" runat="server" Value='<%# Eval("roleId") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Role Name">
                <HeaderStyle HorizontalAlign="Left" />
                <ItemTemplate>
                    <%#Eval("roleName") %>
                </ItemTemplate>
                <EditItemTemplate>
                   <asp:TextBox runat="server" ID="txtRoleName" Text='<%# Eval("roleName")%>'  />
                </EditItemTemplate>
                 <FooterTemplate>
                      <asp:TextBox ID="txtRoleName" runat="server" Text='<%#Eval("roleName")%> '></asp:TextBox>
                    </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Description">
                <HeaderStyle HorizontalAlign="Left" />
                <ItemTemplate>
                    <%#Eval("Description")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtRoleDesc" runat="server" Text='<%# Eval("Description")%>'></asp:TextBox>
                </EditItemTemplate>
                 <FooterTemplate>
                      <asp:TextBox ID="txtRoleDesc" runat="server"  Text='<%#Eval("Description")%>'></asp:TextBox>
                      <asp:Button ID="btnInsert" runat="Server" Text="Insert" CommandName="Insert" UseSubmitBehavior="False" OnClientClick="return validateTextBox();" />
                    </FooterTemplate>
            </asp:TemplateField>
           </Columns>
        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
        <SortedAscendingCellStyle BackColor="#F1F1F1" />
        <SortedAscendingHeaderStyle BackColor="#594B9C" />
        <SortedDescendingCellStyle BackColor="#CAC9C9" />
        <SortedDescendingHeaderStyle BackColor="#33276A" />
        <EmptyDataTemplate>
            Name <asp:TextBox ID="txtRoleName" runat="Server"></asp:TextBox>
            Description <asp:TextBox ID="txtRoleDescription" runat="Server"></asp:TextBox> 
            <asp:Button ID="btnRoleInsert" runat="Server" Text="Insert" CommandName="RoleInsert" UseSubmitBehavior="False" />
        </EmptyDataTemplate>
    </asp:GridView>

</td>
</tr>
</table>
</asp:Content>
